package persistencia;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import modelo.Funcionario;

import org.ksoap2.serialization.PropertyInfo;
import org.ksoap2.serialization.SoapObject;
import org.xmlpull.v1.XmlPullParserException;

public class DALFuncionario {

	public Funcionario Autenticar(String strLogin, String strSenha) throws IOException, XmlPullParserException {
		
		List<PropertyInfo> lsPI = new ArrayList<PropertyInfo>();
		
		PropertyInfo pi0 = new PropertyInfo();
		pi0.setName("strChave");
		pi0.setValue("abc123");
		lsPI.add(pi0);
		
		PropertyInfo pi = new PropertyInfo();
		pi.setName("strLogin");
		pi.setValue(strLogin);
		lsPI.add(pi);
		
		PropertyInfo pi1 = new PropertyInfo();
		pi1.setName("strSenha");
		pi1.setValue(strSenha);
		
		lsPI.add(pi1);
				
		WebServices ws = new WebServices();
		SoapObject result = ws.WebServices("Autenticar",lsPI);
		
		Funcionario oFuncionario = new Funcionario();
		if (result != null){
				
				oFuncionario.setIdFuncionario(result.getProperty("idFuncionario").toString());
				oFuncionario.setIdEquipe(result.getProperty("idEquipe").toString());
				oFuncionario.setNome(result.getProperty("Nome").toString());
				oFuncionario.setLogin(result.getProperty("Login").toString());
				oFuncionario.setSenha(result.getProperty("Senha").toString());
				oFuncionario.setResponsavel(result.getProperty("Responsavel").toString());
		}else 
			oFuncionario = null;
				
		return oFuncionario;

	}
}
